<%@page import="edu.uit.se.laps.web.model.TaiKhoan"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!-- pageEncoding="UTF-8"%> -->
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ page
	import="edu.uit.se.laps.web.*,edu.uit.se.laps.web.controller.*, java.net.*,java.text.*,java.util.*"%>

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body,input {
	font-family: Calibri, Arial;
}

table#contact {
	border-collapse: collapse;
	width: 550px;
}

th {
	height: 40px;
	background-color: #ffee55;
}
</style>
<title>myLife - Quản Lý Khách Hàng</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script language="javascript" src="1.7.2.jquery.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$('.tb_donhang').css({'margin':'50px 0px'});
		$('table').css({'border-collapse':'collapse'});
		$('table td').css({'border':'1px solid black','height':'30px', 'padding':'4px'});
		$('table th').css({'border':'2px solid green','padding':'4px'});
		$('.themSP').css({'float':'left', 'height':'30px', 'background':'#B20000'});
		$('.themSP a').css({'text-decoration':'none', 'padding':'0px 4px', 'color':'white', 
			'line-height':'30px'});
	});
</script>

</head>
<body>
<tiles:insertTemplate template="TemAdmin.jsp">
		<tiles:putAttribute name="adminFocus">
	<div  class="tb_donhang" align="center">
	<%
		TaiKhoanSession tkSession = (TaiKhoanSession) session.getAttribute("TaiKhoanSession");
		if (tkSession == null) {
			tkSession = new TaiKhoanSession();
			session.setAttribute("TaiKhoanSession", tkSession);
		}
		TaiKhoan tk = tkSession.getTk();
		
		List tkList = tkSession.getTKList();
		if (tkList.size() != 0) {
	%>
	
	<h1>DANH SÁCH KHÁCH HÀNG</h1>

	<div  class="themSP"><a href="adduser.jsp">Thêm khách hàng</a></div><br><br>

	<table id="user" border="1">
		<tr>
			<th>Id User</th>
			<th>Email</th>
			<th>Password</th>
			<th>Họ Tên</th>
			<th>Giới Tính</th>
			<th>Điện Thoại</th>
			<th>Địa Chỉ</th>
			<th>Ngày Đăng Kí</th>
			<th>Ngày Sinh</th>
			<th>Chỉnh sửa</th>
			<th>Xóa</th>
			<%				
				for (int i = 0; i < tkList.size(); i++) {
					TaiKhoan tkTemp = (TaiKhoan) tkList.get(i);				
			%>
		</tr>
		<tr>
			<td><%= tkTemp.getIdUser() %></td>
			<td><%= tkTemp.getEmail() %></td>
			<td><%= tkTemp.getPassword() %></td>
			<td><%= tkTemp.getHoTen() %></td>
			<%
				if (tkTemp.isGioiTinh() == true) {			
			%>
			<td>Nữ</td>
			<%
				}
				else {
			%>
			<td>Nam</td>
			<%
				}
			%>
<%-- 			<td><%= tkTemp.getGioiTinh() %></td> --%>
			<td><%= tkTemp.getDienThoai() %></td>
			<td><%= tkTemp.getDiaChi() %></td>
			<td><%= tkTemp.getNgayDangKi() %></td>
			<td><%= tkTemp.getNgaySinh() %></td>
			<td>
				<s:form action="showUpdateUser" method="post">
					<input type="hidden" name="idUser" value='<%=tkTemp.getIdUser()%>'/>
					<input type="submit" value="Cập nhật"/>
				</s:form>
			</td>				
			<td>
				<s:form action="deleteUser" method="post">
					<input type="hidden" name="idUser" value='<%=tkTemp.getIdUser()%>'/>
					<input type="submit" value="Xóa tài khoản"/>
				</s:form>
			</td>
		</tr>
		<%
			}
		%>
	</table>
	<%
		}
	%>
 
 
	</div>
	</tiles:putAttribute>
	</tiles:insertTemplate>
</body>
</html>